package ${packageName}.bean;
import cn.ygh.bbo.common.annotation.Excel;
import cn.ygh.bbo.framerwork.core.BaseEntity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.math.BigDecimal;
import java.text.*;
import java.util.*;
import lombok.Data;
import org.apache.commons.lang3.builder.*;
/**
* 描述：${clazz.remark}
* @author ygh
*/
<#--@ApiModel-->
@TableName("${clazz.clazzName}")
@Data
public class ${clazz.name} extends BaseEntity {
    /*数据库字段——start*/
        <#list clazz.fields as field>
    /**
    * ${field.remark}
    */
    @Excel("${field.remark}")
     <#if field.primary>
         <#if field.auto>
    @TableId(type = IdType.AUTO)
             <#else >
    @TableId(type = IdType.INPUT)
         </#if>
     <#else >
     </#if>
    @TableField(value = "${field.fieldName}")
    private ${field.type} ${field.name};

        </#list>

    /*数据库字段——end*/

    <#--默认值设置-->
    /**
    * 默认值设置
    * @return
    */
    public ${clazz.name} def(){
        return this;
    }

     /*构造函数——start*/
    public ${clazz.name}() {
    }

    public ${clazz.name}(${clazz.id.type} id) {
        this.id=id;
    }

    /**
    *构造函数
    */
    <#assign index=0/>
    public ${clazz.name}(<#list clazz.fields as field><#if !field.auto><#if index != 0>,</#if><#assign index=index+1/>${field.type} ${field.name}</#if></#list>) {
        <#list clazz.fields as field>
            <#if !field.auto >
        this.${field.name}=${field.name};
            </#if >
        </#list>
    }
    /*构造函数——end*/

    /*非数据库字段——start*/
<#list clazz.fields as field>
<#if field.type=="Date">
    /**
    * ${field.remark}开始
    */
    @TableField(exist = false)
    private ${field.type} ${field.name}BeginValue;

    /**
    * ${field.remark}结束
    */
    @TableField(exist = false)
    private ${field.type} ${field.name}EndValue;

</#if>
</#list>
    /*非数据库字段——end*/

     <#--hash-->
    /**
	 * Hash，同所有字段相加判断
	 */
	@Override
	public int hashCode() {
		if(get${clazz.id.name?cap_first}()==null){
            return new HashCodeBuilder()
        <#list clazz.fields as field>
            <#if !field.primary >
            .append(get${field.name?cap_first}())
            </#if>
        </#list>
			.toHashCode();
        }
		return new HashCodeBuilder()
			.append(get${clazz.id.name?cap_first}())
			.toHashCode();
	}
    <#--equals-->
    /**
	 * 重写，对象是否相同，用ID来判断
	 */
	@Override
	public boolean equals(Object obj) {
		if(!(obj instanceof ${clazz.name})) {
			return false;
		}
		if(this == obj) {
			return true;
		}
        ${clazz.name} other = (${clazz.name})obj;
		return new EqualsBuilder()
			.append(get${clazz.id.name?cap_first}(),other.get${clazz.id.name?cap_first}())
			.isEquals();
	}
    <#--toString-->
	/**
	 * 转文本
	 */
	@Override
	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.SHORT_PREFIX_STYLE)
			.append(super.toString())
            <#list clazz.fields as field>
            .append(",${field.name?cap_first}",get${field.name?cap_first}())
            </#list>
			.toString();

	}

/*
//精简构造 ${clazz.remark}
${clazz.name} ${clazz.name?uncap_first} = new ${clazz.name}(
    <#assign index=0 />
    <#list clazz.fields as field>
        <#if !field.auto>
            <#if index!=0>,</#if>${field.name} //${field.remark}
            <#assign index=index+1 />
        </#if>
    </#list>
);
*/
}